<template>
	<view class="phone_login">
		<view class="top_text">
			欢迎来到小程序
		</view>
		<view class="content">
			<view class="input_box_text">
				<u-input placeholder="输入手机号" prefixIcon="/static/login/1.png"
					:prefixIconStyle="{width:'30rpx',height:'30rpx'}" border="none" v-model="value.phoneNum"
					@change="change"></u-input>
			</view>
			<view class="input_box_check mt-20 relative">
				<!-- #ifndef APP-NVUE -->
				<u-input placeholder="输入验证码" prefixIcon="/static/login/3.png"
					prefixIconStyle="font-size: 22px;color: #909399;width:30rpx;height:30rpx" border="none"  v-model="value.checkNum">
				<!-- #endif -->
					<!-- #ifdef APP-NVUE -->
					<u--input placeholder="输入验证码" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399;width:30rpx;height:30rpx"
						border="none" v-model="value.checkNum">
					<!-- #endif -->
						<template slot="suffix">
							<u-code ref="uCode" @change="codeChange" seconds="20" changeText="X秒重新获取哈哈哈"></u-code>
							<text @tap="getCode" style="font-size: 24rpx;">发送验证码</text>
							<!-- class="check_btn" -->
						</template>
				<!-- #ifndef APP-NVUE -->
				</u-input>
				<!-- #endif -->
				<!-- #ifdef APP-NVUE -->
				</u--input>
				<!-- #endif -->
			</view>
			<view class="submit">
				<u-button @click="submit" type="default" shape="circle" color="#CEEE5B" hairline="false" text="登录">
					<text style="color: black;">登录</text>
				</u-button>
			</view>
			<!-- <view class="text-center mt-20 to_reg" @click="toReg">
				没有账号？去注册
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: {
					phoneNum: null,
					checkNum: null,
					tips: null,
				}
			}
		},
		methods: {
			change(e) {
				console.log(e);
			},
			submit() {
				console.log(this.value)
				uni.navigateTo({
					url: '/subpack/login/uploadavater'
				})
			},
			toReg() {
				uni.navigateTo({
					url: '/subpackPage/regist/regist'
				})
			},
			codeChange(text) {
				this.tips = text;
			},
			getCode() {
				if (this.$refs.uCode.canGetCode) {
					// 模拟向后端请求验证码
					uni.showLoading({
						title: '正在获取验证码'
					})
					setTimeout(() => {
						uni.hideLoading();
						// 这里此提示会被this.start()方法中的提示覆盖
						uni.$u.toast('验证码已发送');
						// 通知验证码组件内部开始倒计时
						this.$refs.uCode.start();
					}, 2000);
				} else {
					uni.$u.toast('倒计时结束后再发送');
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.phone_login {
		padding: 100rpx;

		.top_text {
			margin-bottom: 250rpx;
			font-size: 39rpx;
			// margin: 160rpx auto 0;
		}

		.content {
			margin-top: 20rpx;

			.input_box_text,
			.input_box_check {
				padding: 24rpx;
				background-color: #d8d8d8;
				border-radius: 100rpx;
				height: 76rpx;
				line-height: 76rpx;
				font-size: 24rpx;
			}

			.input_box_text {
				padding: 16rpx;
			}

			.input_box_check {
				padding: 0 24rpx;

				.check_btn {
					position: absolute;
					// right: 30rpx;
					// top: 10rpx;
					font-size: 27rpx;
					color: #444444;
				}
			}

			.submit {
				margin-top: 200rpx;
				border-radius: 100rpx;

				u-button {
					color: #000 !important;
				}
			}

			.to_reg {
				font-size: 27rpx;
			}
		}
	}

	.mt-20 {
		margin-top: 20rpx;
	}
</style>